feat(extraction): EXP-06 — generic event anchors for As-of facts#7
Draft
moralespanitz wants to merge 1 commit intomainfrom
Draft
feat(extraction): EXP-06 — generic event anchors for As-of facts#7moralespanitz wants to merge 1 commit intomainfrom
moralespanitz wants to merge 1 commit intomainfrom
Conversation
When a fact starts with 'As of <date>, ...' and no DESCRIPTOR_RULE matches, emit a generic event.occurred anchor with the date and subject recovered from the prefix. Behind new flag genericEventAnchorEnabled (default false). Targets BEAM TR. Stage 7 dry-run on iter 7 v3 had TR 1/2 and EO 0/2; much of the variance was on facts that had clear temporal phrasing but didn't match LoCoMo-style descriptors. The fall-through anchor restores them at retrieval time. Risks: anchor inflation (new flag is off by default to bound this); subject collapse on User-only facts (subject extractor returns null in ambiguous cases rather than emitting a wrong subject). New config keys (defaults-off): - genericEventAnchorEnabled: false Behind feature flag. Defaults preserve current behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a fact begins with
As of <date>, ...and noDESCRIPTOR_RULEmatches but a subject is recoverable, emit a genericevent.occurredanchor with the date and subject. Behind a new feature flaggenericEventAnchorEnabled(defaultfalse).This is EXP-06 from the Sprint 2 phase-2 implementation plan.
Why this exists
event-anchor-facts.tsships a list of LoCoMo-styleDESCRIPTOR_RULES(mentorship, internship, networking, Paris/Rome trips, etc.). Any BEAM fact with anAs of <date>,prefix that doesn't match one of those rules is emitted without an anchor and is invisible to the temporal-anchor retrieval path.The Stage 7 dry-run on iter 7 v3 measured TR 1/2 and EO 0/2; manual inspection of the failing facts showed clear temporal phrasing (
As of January 2026, user is using PostgreSQL,As of March 15 2025, user completed the API migration) that the rules silently dropped.The fall-through anchor restores those facts at retrieval time without any new LLM call.
The rule
In
inferDescriptors:DESCRIPTOR_RULESloop.descriptors.length === 0ANDoptions.genericEventAnchorEnabled === true, push{ label: 'event.occurred', subject, eventDateIso }and let the rest of the pipeline build the anchor fact.inferSubjecthelper, which already returnsnull(no anchor) when neither a person entity nor\buser\bis present in the fact text.The recorded-date prefix parser is widened to accept
Month Year(e.g.January 2026) in addition to the existingMonth Day Yearform. When only month-year is present, the synthesized event date is the first day of the month — sufficient for retrieval keying.Risks
As of <date>,fact becomes at least one anchor. The flag is off by default to bound this.User.inferSubjectfalls back toUserwhen no person entity is present. This weakens multi-event ordering (an EO concern, addressed by EXP-13). Subject extraction returnsnullrather than guessing for ambiguous inputs.descriptors.length === 0guard ensures we never double-emit on a single fact. Existing LoCoMo regression tests still pass with the flag on.event_boundary/boundary_probfields the LLM-judged extraction adds — anchors get their own retrieval boost.Test cases
src/services/__tests__/event-anchor-facts.test.ts— extended:As of January 2026, user is using PostgreSQL.(month-year prefix, flag on).As of March 15 2025, user completed the API migration.(full-date prefix, flag on).As of <date>prefix (flag on).mentorship.receivedstill fires for the existing LoCoMo fixture, and the generic fall-through does not also fire on the same source fact when the flag is on.[](no anchor) onAs of January 2026, the situation continues.rather than crashing or guessing.Random unstructured text without temporal prefix.) returns[]without throwing.All 12 tests pass (5 existing regression + 7 new). Related runtime-config tests for
consensusExtractFactswere updated to thread the new field through and all 18 of those continue to pass.Config override
To enable for a single ingest call without restarting the server:
{ "config_override": { "genericEventAnchorEnabled": true } }Or via env:
The field is also added to
INTERNAL_POLICY_CONFIG_FIELDSsoPUT /v1/memories/configaccepts it on dev/test deployments.Wiring
RuntimeConfig.genericEventAnchorEnabled: boolean(default false).IngestRuntimeConfigextended with the same field;MemoryServiceDeps.configalready pulls it through& IngestRuntimeConfig.ConsensusExtractionConfig.genericEventAnchorEnabled: boolean—buildExtractionOptionsforwards it intoextractFacts(...).ExtractionOptions.genericEventAnchorEnabled?: boolean(inobservation-date-extraction.ts, the existing pattern).extraction.ts:323forwards the flag intoenrichExtractedFacts(..., { genericEventAnchorEnabled }).enrichExtractedFactsandinferEventAnchorFactsaccept the new option; default-off preserves bit-identical output.quickExtractFactsaccepts an optionalEnrichmentOptions;memory-ingest.ts:performQuickIngestthreadsdeps.config.genericEventAnchorEnabledthrough so the quick path also benefits.Test plan
npx tsc --noEmit— exit 0npx vitest run src/services/__tests__/event-anchor-facts.test.ts— 12/12 passingnpx vitest run src/services/__tests__/consensus-extraction-runtime-config.test.tsobservation-date-extraction.test.tsquick-extraction-assistant.test.ts— 18/18 passingnpx vitest run src/services/__tests__/extraction.test.tsextraction-enrichment.test.tsextraction-cache.test.ts— 64/64 passingnpx vitest run src/services/__tests__/memory-ingest-runtime-config.test.tsingest-trace-branches.test.ts— 12/12 passing